﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:GalaSoft_MvvmLight_Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL4" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
    xmlns:cx="clr-namespace:uTorrentSL.Behaviors"
    xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
    xmlns:ee="http://schemas.microsoft.com/expression/2010/effects"
    x:Class="uTorrentSL.MainPage"
    mc:Ignorable="d"
    d:DesignWidth="740" d:DesignHeight="300"
     DataContext="{Binding Main, Source={StaticResource Locator}}">
	
    <Grid x:Name="LayoutRoot" Style="{StaticResource LayoutRootGridStyle}" Background="Transparent">
    	
			<Grid.RowDefinitions>
				<RowDefinition Height="80"/>
				<RowDefinition Height="*"/>
				<RowDefinition Height="25"/>
			</Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
        	<ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

    	

            <Border x:Name="BackgroundBorder" Style="{StaticResource ContentBorderStyle}" Grid.RowSpan="3" Margin="10" />

			<Border x:Name="BrandingBorder" Style="{StaticResource NavBrandingBorderStyle}" Margin="62,10,11,0">
				<Grid x:Name="BrandingStackPanel" >
					
					<Button x:Name="hlBack" Padding="5,-2,5,0" Content="←" VerticalAlignment="Top" HorizontalAlignment="Left" Height="23" Canvas.ZIndex="5" IsEnabled="{Binding CanGoBack, ElementName=ContentFrame}" >
						<i:Interaction.Triggers>
							<i:EventTrigger EventName="Click">
								<ei:CallMethodAction TargetObject="{Binding ElementName=ContentFrame}" MethodName="GoBack"/>
								<ei:SetDataStoreValueAction TargetObject="{Binding MainContent}" Value="{Binding Source, ElementName=ContentFrame}"/>
							</i:EventTrigger>
						</i:Interaction.Triggers>
					</Button>
					<TextBlock x:Name="ApplicationNameTextBlock" Style="{StaticResource ApplicationNameStyle}" Text="µTorrent-SL" Margin="6,2,0,0" UseLayoutRounding="True" />
					<ContentControl Style="{StaticResource LogoIcon}" Margin="300,0,30,0" HorizontalAlignment="Right"/>
					
					<Grid Margin="0,0,30,0" HorizontalAlignment="Right" Width="280" Height="44" VerticalAlignment="Top">
						<Grid.RowDefinitions>
							<RowDefinition/>
							<RowDefinition/>
						</Grid.RowDefinitions>
						<HyperlinkButton Margin="-5,-4,0,0" HorizontalAlignment="Left" FontSize="15" Style="{StaticResource LinkStyle}" Grid.Row="1" Content="{Binding Username, Source={StaticResource Locator}}" Grid.RowSpan="2" VerticalAlignment="Top">
							<i:Interaction.Triggers>
								<i:EventTrigger EventName="Click">
									<GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding SetControl}" CommandParameter="Home"/>
								</i:EventTrigger>
							</i:Interaction.Triggers>
						</HyperlinkButton>
						<HyperlinkButton Margin="2,0,0,0" HorizontalAlignment="Left" FontSize="15" Style="{StaticResource LinkStyle}" Content="{Binding HostPort, Source={StaticResource Locator}}" VerticalAlignment="Top">
							<i:Interaction.Triggers>
								<i:EventTrigger EventName="Click">
									<GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding SetControl}" CommandParameter="Home"/>
								</i:EventTrigger>
							</i:Interaction.Triggers>
						</HyperlinkButton>
					</Grid>
				</Grid>
			</Border>

			<Border x:Name="LinksBorder" Style="{StaticResource NavLinksBorderStyle}" Margin="11,0,0,0" Grid.RowSpan="2" Grid.Row="1">
				<StackPanel x:Name="LinksStackPanel" Style="{StaticResource LinksStackPanelStyle}" Margin="28,0,0,0">

                <HyperlinkButton Style="{StaticResource LinkStyle}" Content="torrents"
				NavigateUri="/Views/TorrentsView.xaml" TargetName="ContentFrame"/>
                <HyperlinkButton Style="{StaticResource LinkStyle}"  Content="feeds"
				NavigateUri="/Views/FeedsView.xaml" TargetName="ContentFrame"/>
                <HyperlinkButton Style="{StaticResource LinkStyle}"  Content="filters"
				NavigateUri="/Views/FiltersView.xaml" TargetName="ContentFrame"/>
                <HyperlinkButton Style="{StaticResource LinkStyle}"  Content="settings" 
				NavigateUri="/Views/SettingsView.xaml" TargetName="ContentFrame"/>
            </StackPanel>
			</Border>
			<Grid Grid.Row="1"   Margin="50,37,11,0">
				<VisualStateManager.VisualStateGroups>
		    		<VisualStateGroup x:Name="Transitions">
		    			<VisualStateGroup.Transitions>
		    				<VisualTransition GeneratedDuration="0:0:0.3">
		    					<ei:ExtendedVisualStateManager.TransitionEffect>                                 
		    						<ee:SlideInTransitionEffect/>                             
								</ei:ExtendedVisualStateManager.TransitionEffect>			
							</VisualTransition>
		    			</VisualStateGroup.Transitions>
		    			<VisualState x:Name="Navigating"/>
		    			<VisualState x:Name="Navigated"/>
		    		</VisualStateGroup>
		    	</VisualStateManager.VisualStateGroups>
				<VisualStateManager.CustomVisualStateManager>
		    		<ei:ExtendedVisualStateManager/>
		    	</VisualStateManager.CustomVisualStateManager>
        		<Border x:Name="ContentBorder">
					<navigation:Frame x:Name="ContentFrame" Source="{Binding MainContent}" RenderTransformOrigin="0.5,0.5" >
						<navigation:Frame.RenderTransform>
							<CompositeTransform TranslateX="1"/>
						</navigation:Frame.RenderTransform>
						<i:Interaction.Triggers>
							<i:EventTrigger EventName="Navigating">
								<ei:GoToStateAction StateName="Navigating"/>
							</i:EventTrigger>
							<i:EventTrigger EventName="Navigated">
								<ei:GoToStateAction StateName="Navigated"/>
							</i:EventTrigger>
						</i:Interaction.Triggers>
					</navigation:Frame>
				</Border>
			</Grid>
		</Grid>
</UserControl>